<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" th:href="@{/css/pintuer.css}">
    <link rel="stylesheet" th:href="@{/css/admin.css}">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <style>
        .cz a{
            border-radius:3px; border:1px solid #dfdfdf;display:inline-block; padding:5px 12px;
        }
        .cz a:hover{background:#09F; color:#FFF; border-color:#09F; }
    </style>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 资源列表</strong></div>
    <div class="padding border-bottom">
       <div class="layui-form-item layui-inline">
            <label class="layui-btn layui-form-label" style="text-align: center" th:onclick="query()">查询</label>
            <div class="layui-input-block">
                <input class="layui-input" id="title" name="title" placeholder="输入文件名" autocomplete="off"/>
            </div>
        </div>
    </div>

    <table id="coursetable" class="table table-hover text-center">
        <tr>
            <th width="10%">标题</th>
            <th width="10%">描述</th>
            <th width="5%">类型</th>
            <th width="10%">分组</th>
            <th width="15%">原名</th>
            <th width="15%">相对路径</th>
            <th width="5%">单价</th>
            <th width="5%">下载量</th>
            <th width="5%">评论量</th>
            <th width="5%">均评价</th>
            <th width="5%">总收入</th>
            <th width="10%">操作</th>
        </tr>
        <tbody>
        <tr th:each="file:${files.getRecords()}">
            <td  th:text="${file.getTitle()}" ></td>
            <td  th:text="${file.getDescription()}" ></td>
            <td  th:text="${file.getType()}" ></td>
            <td  th:text="${file.getFgname()}" ></td>
            <td  th:text="${file.getOldname()}" ></td>
            <td  th:text="${file.getRelativepath()}" ></td>
            <td ><span th:text="${file.getPrice()}"></span></td>
            <td ><span th:text="${file.getDownup()}"></span></td>
            <td ><span th:text="${file.getCommentsNum()}"></span></td>
            <td ><span th:text="${file.getAverage()}"></span></td>
            <td ><span th:text="${file.getSumprice()}"></span></td>
            <td  class="cz">
                <a id="bj" th:onclick="'update('+${file.getFileId()}+')'"><i class="layui-icon">&#xe642;</i></a>
                <a th:href="@{/file/delFile/}+${file.getFileId()}"><i class="layui-icon">&#xe640;</i></a>

            </td>
        </tr>
        </tbody>
        <tr>
            <td colspan="12">
                <div class="pagelist">
                    <a id='first_page'  th:onclick="page(4)">首页</a>
                    <a id='last_page'   th:onclick="page(1)">上一页</a>
                    <a id='next_page'   th:onclick="page(2)">下一页</a>
                    <a id='end_page'    th:onclick="page(5)">尾页</a>
                    <a id='jump_page'   th:onclick="page(3)">跳转</a>
                    <input id="page_no" style="height: 20px;width:30px" th:value="${files.getCurrent()}"/>
                    <span th:text="'共'+${files.getTotal()}+'条分'+${files.getPages()}+'页'"></span>
                    <input id="size"  style="height: 20px;width:30px" th:value="${files.getSize()}"/>
                    <a id=''   th:onclick="page(0)">设置</a>
                </div>
            </td>
        </tr>
    </table>
</div>

</body>
<script th:src="@{/js/jquery-2.1.0.js}"></script>
<script th:src="@{/js/pintuer.js}"></script>
<script th:src="@{/layui/layui.js}"></script>
<script th:inline="javascript">

    function page(x) {
        var  page=[[${files.getCurrent()}]];
        var end_page=[[${files.getPages()}]];
        var downPage = page+1;
        var topPage = page-1;
        var page_no=$("#page_no").val();
        var size=$("#size").val();
        if (x==3&&page_no>=1&&page_no<=end_page){

            window.location.href="/file/data_file?pageNum="+page_no+"&size="+size;
        }
        if (x==0){
            window.location.href="/file/data_file?size="+size;
        }
        if (x==1&&page>1){

            window.location.href="/file/data_file?pageNum="+topPage+"&size="+size;
        }
        if (x==2&&page<end_page){

            window.location.href="/file/data_file?pageNum="+downPage+"&size="+size;
        }
        if (x==4){
            window.location.href="/file/data_file?size="+size;
        }
        if (x==5){
            window.location.href="/file/data_file?pageNum="+end_page+"&size="+size;
        }
    }
    function query() {
        var title=$("#title").val();
        var size=$("#size").val();
        window.location.href="/file/data_file?title="+title+"&size="+size;
    }
    layui.use('layer',function(){
        var layer=layui.layer;
    });

    function update(fileId){
        alert(fileId);
        layer.open({
            type: 2,
            area: ['615px', '360px'],
            resize: false,
            shadeClose: true, //点击遮罩关闭
            content: [[@{/file/editFile/}]]+fileId
    });
    }
</script>

</html>